package com.cuanbobox.adapter;

import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cuanbobox.bean.InOutBean;
import com.cuanbobox.cbavcx.R;
import com.cuanbobox.constant.InColorConstant;

import java.util.List;

public class InOutAdapter extends BaseQuickAdapter<InOutBean, BaseViewHolder> {

    public InOutAdapter(List<InOutBean> data) {
        super(R.layout.adapter_inout_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, InOutBean item) {

        if (item.getType() == 1) {//输出
            helper.setText(R.id.tvOutId, "" + item.getId());
            helper.setText(R.id.tvId, "" + item.getVsw());
            if (item.getVsw() == 0) {
                helper.setBackgroundRes(R.id.tvId, InColorConstant.inColors[item.getVsw()]);
            } else {
                helper.setBackgroundRes(R.id.tvId, InColorConstant.inColors[item.getVsw() - 1]);
            }
        } else {
            helper.setText(R.id.tvId, "" + item.getId());
            helper.setBackgroundRes(R.id.tvId, InColorConstant.inColors[item.getId() - 1]);
        }
        if (TextUtils.isEmpty(item.getRes())) {
            helper.setText(R.id.tvRes, "");
        } else {
            String res = item.getRes().trim();
            if (res.equals("NoSignal")) {
                helper.setText(R.id.tvRes, "无信号");
            } else {
                helper.setText(R.id.tvRes, "" + item.getRes().trim());
            }
        }
        helper.setText(R.id.tvName, "" + item.getName());
        if (item.isCheck()) {
            helper.setTextColor(R.id.tvOutId, 0xffffffff);
            helper.setTextColor(R.id.tvRes, 0xffffffff);
            helper.setTextColor(R.id.tvName, 0xffffffff);
            helper.setBackgroundRes(R.id.rlBg, R.drawable.in_out_check_bg);
        } else {
            helper.setTextColor(R.id.tvOutId, 0xffcfdbee);
            helper.setTextColor(R.id.tvRes, 0xffcfdbee);
            helper.setTextColor(R.id.tvName, 0xffcfdbee);
            helper.setBackgroundRes(R.id.rlBg, R.drawable.in_out_uncheck_bg);
        }

        if (item.getType() == 0) {
            helper.setVisible(R.id.tvOutId, false);
        }
    }


}